#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

int main()
{
	printf("stdin-> %d\n",stdin->_fileno);
	printf("stdout-> %d\n",stdout->_fileno);
	printf("stderr-> %d\n",stderr->_fileno);

	int logfd = open("log.txt",O_WRONLY|O_TRUNC|O_CREAT,0666);
	char* buff = "111111aaaaaa\n";
	int len = strlen(buff);
	int num = write(logfd,buff,strlen(buff));
	printf("logfd-> %d:num-> %d:len-> %d\n",logfd,num,len);
	close(logfd);

	int logfd2 = open("log.txt",O_RDONLY,0666);
	char buff2[120] = {0};
	int num2 = read(logfd2,buff2,120);
	printf("logfd-> %d:num-> %d:buff2-> %s\n",logfd2,num2,buff2);
	close(logfd2);

	return 0;
}
